<?php

namespace app\api\model;
use GatewayClient\Gateway;

class PrivatechatDeleTask extends Common
{
    public static function pushtask($userid, $real_uid = 0)
    {
        if (!$real_uid) {
            $real_uid = $userid;
        }
        $client = getenv('SOCKET_PREFIX') . $real_uid;

        if(sizeof(Gateway::getClientIdByUid($client))){
            
            $PrivatechatDeleTask = new PrivatechatDeleTask;
            $list = $PrivatechatDeleTask::where(['state'=>0, 'userid'=>$userid])->limit(1000)->select();

            $message = json_encode([
                "code" => 200,
                "action" => 'api/Privatechat/deletetask',
                'data' => $list
            ]);

            Gateway::sendToUid($client, $message);
        }
    }
}
